home *** CD-ROM | disk | FTP | other *** search
- class Twin extends MovieClip
- {
- var twin_points;
- var movement;
- var onEnterFrame;
- var resting_position;
- var is_available;
- var follower;
- var Char;
- var randSpot;
- var RUN_AWAY_SPEED = 8.5;
- var RUN_AWAY_TIMER = 10;
- function Twin()
- {
- super();
- _global[this._name] = this;
- _global.MallCrawl.twinsArray.push(this);
- this.twin_points = 50;
- this._xscale = 45;
- this._yscale = 45;
- this.movement = [];
- this.cacheAsBitmap = true;
- this.getNewSpot();
- this.sendToSpot();
- this.onEnterFrame = this.defaultEnterFrame;
- this.gotoAndStop("still");
- }
- function defaultEnterFrame()
- {
- this._x = _level0.Background._x + this.resting_position.x;
- this.is_available = true;
- }
- function fadeAlpha(amt)
- {
- this._alpha = amt;
- this.follower.fadeAlpha(this._alpha);
- return this._alpha;
- }
- function fillMovement()
- {
- var _loc3_ = 0;
- while(_loc3_ < _global.MallCrawl.FOLLOWER_DISTANCE)
- {
- this.movement.push({x:this._x,y:this._y - _global.Rescuer.HEIGHT_MINUS,scale:this._xscale,moving:this.Char._currentframe > 1});
- if(this.movement.length > _global.MallCrawl.FOLLOWER_DISTANCE)
- {
- this.follower.twinMovement(this.movement.popFirst());
- }
- _loc3_ = _loc3_ + 1;
- }
- this.follower.fillMovement();
- }
- function addFollower(mc)
- {
- mc.onEnterFrame = function()
- {
- this._alpha = _global.Rescuer._alpha;
- };
- mc.gotoAndStop("walk");
- _global.MallCrawl.tcounterArray.push(mc);
- this.follower = _global.MallCrawl.twinsArray.popByName(mc);
- this.follower.movement = new Array();
- }
- function getNewSpot()
- {
- this.randSpot = _global.MallCrawl.randomTwinSpots.popById(random(_global.MallCrawl.randomTwinSpots.length - 1));
- }
- function twinMovement(obj)
- {
- if(obj.moving)
- {
- this.Twin.gotoAndStop("walk");
- }
- else
- {
- this.Twin.gotoAndStop("still");
- }
- this._x = obj.x;
- this._y = obj.y + (_global.Rescuer._height - this._height);
- if(obj.scale < 0)
- {
- this._xscale <= 0 ? null : (this._xscale *= -1);
- }
- else
- {
- this._xscale >= 0 ? null : (this._xscale *= -1);
- }
- if(this.follower)
- {
- this.movement.push(obj);
- if(this.movement.length > _global.MallCrawl.FOLLOWER_DISTANCE)
- {
- this.follower.twinMovement(this.movement.popFirst());
- }
- }
- }
- function runAway(parent)
- {
- _global.MallCrawl.twinsArray.push(parent.follower);
- parent.follower = undefined;
- this.Twin.gotoAndStop("walk");
- this.is_available = false;
- while(this.movement.length)
- {
- this.movement.pop();
- }
- this.movement = new Array();
- this._alpha = 100;
- this._y = _global.MallCrawl["GLevel" + _global.Rescuer.glevel]._y - this._height;
- var d = random(2);
- d != 0 ? null : (d = -1);
- var birth = getTimer();
- this.onEnterFrame = function()
- {
- if(getTimer() < birth + this.RUN_AWAY_TIMER * 1000)
- {
- this._x += this.RUN_AWAY_SPEED * d;
- }
- else
- {
- this.getNewSpot();
- this.sendToSpot();
- this.onEnterFrame = this.defaultEnterFrame;
- }
- };
- }
- function sendToSpot()
- {
- this._x = this.randSpot._x;
- this._y = this.randSpot._y;
- this.resting_position = {x:this._x,y:this._y};
- this.Twin.gotoAndStop("still");
- }
- }
-